package com.hzbank.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.hzbank.dto.User;
import com.hzbank.service.UserService;

@RestController
public class UserController {
	@Autowired
	private UserService userService;
	
	@RequestMapping(value="/adduser",method=RequestMethod.GET)
	public String adduser(User user){
		boolean flag= userService.insert(user);
		if(flag==true){
			return "success";
		}
		return "error";
	}
	
	@RequestMapping(value="/search",method=RequestMethod.GET)
	public List<User> search(String search){
		List<User> listUser= userService.search(search);
		return listUser;
	}
	
	@RequestMapping(value="/pageUsers")
	public List<User> pageUsers(Integer pageNumber,Integer pageSize,String searchContent){
		List<User> listUser= userService.searchUser(pageNumber, pageSize, searchContent);
		return listUser;
	}
	@RequestMapping(value="/allUser")
	public List<User> matchfindall(){
		List<User> listUser= userService.matchfindall();
		return listUser;
	}
	
	@RequestMapping(value="/compoundquery")
	public List<User> compoundquery2(String name,String description){
		List<User> listUser= userService.compoundquery2(name,description);
		return listUser;
	}
	
}
